#include <stdio.h>
#include <sys/mman.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>

int main(int argc, char const *argv[])
{
    int lcd_fd = open("/dev/fb0",O_RDWR);
    int color[2] = {0xFF,0xFF00};
    if (lcd_fd < 0)
    {
        perror("fd failed to open");
        return -1;
    }


    char *p = mmap(NULL,800*480*4,PROT_WRITE | PROT_READ,MAP_SHARED,lcd_fd,0);
    if (p == MAP_FAILED)
    {
        perror("映射失败");
        return -1;
    }
    for (int y = 0; y < 480; y++)
    {
        for (int x = 0; x < 800; x++)
        {
            if (y >= x && y <= x + 5)
            {
                memcpy(p + 4*x + 800*y*4,&color[0],4);
            }
            else    
                memcpy(p + 4*x + 800*y*4,&color[1],4);
        }
    }
    
    munmap(p,800*480*4);
    close(lcd_fd);
    
    return 0;
}
